package com.ruoyi.web.mapper;


import com.ruoyi.web.controller.domain.News;
import lombok.Data;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.aspectj.lang.annotation.DeclareError;

import java.util.ArrayList;
import java.util.List;

@Mapper
public interface NewsMapper {

//    id,title,image_url
    @Select("select id,title,source,image_url as imageUrl from  news order by id desc limit 5")
    public List<News> list();

    @Insert("Insert into news (title,content,image_url,publish_time,source) values (#{title},#{content},#{imageUrl},#{publishTime},#{source})")
    public void insertNews(News news);

    @Select("select * from news where id=#{Id}")
    News getById(Long Id);


    @Delete("DELETE n1 FROM news n1 JOIN (SELECT id FROM news ORDER BY id ASC LIMIT 5) n2 ON n1.id = n2.id")
    public void deleteNews();
}
